import ajax from '../utils/request'

// 获取频道列表
export const getChannels = () => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/user/channels'
  })
}

// 不喜欢文章   /app/v1_0/article/dislikes
export const userArticleLike = (articleid) => {
  return ajax({
    url: '/app/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: articleid
    }
  })
}

/**
   * 举报文章
   * @param {*} articleId  文章编号
   * @param {*} reportType 举报类型
   */
export const report = (articleId, reportType) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/article/reports',
    data: {
      target: articleId,
      type: reportType
    }
  })
}

// 获取所有频道列表
export const getChannelsList = () => {
  return ajax({
    url: '/app/v1_0/channels',
    method: 'GET'
  })
}

// 添加频道
export const addChannels = (channels) => {
  return ajax({
    method: 'PUT',
    url: '/app/v1_0/user/channels',
    data: {
      channels: channels
    }
  })
}

// 删除频道
export const delChannel = (channelId) => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/user/channels/' + channelId
  })
}
